Skip to content

Conversation

@jackaperkins
Copy link

image

This toggles a dropUpdates value inside of the webxdc shim for a particular instance. When new updates come in they will be 'dropped' and not passed into the application. This lets you test what happens when certain devices miss a message!

This doesn't permanently modify the set of updates, so any app the replays them starting from the beginning will see the 'dropped' updates after being restarted. Doing this would require a refactor where we keep track of each instance's update set independently and to properly enumerate them over the websocket connection, probably not worth it for now.

Copy link
Contributor

@hpk42 hpk42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

README.md Outdated
Comment on lines 101 to 104
on a specific instance. While enabled the instance will not recieve any updates
as if the transport has failed to deliver them. On
later reloads of the page the instance will load all updates as this state is
shared identically between all insances.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is not clear enough that this is just a quirk of the current simulator implementation.

and some typos:

Suggested change
on a specific instance. While enabled the instance will not recieve any updates
as if the transport has failed to deliver them. On
later reloads of the page the instance will load all updates as this state is
shared identically between all insances.
on a specific instance. While enabled the instance will not receive any updates
as if the transport has failed to deliver them. On
later reloads of the page the instance will load all updates as this state is
shared identically between all instances.

Copy link
Member

@WofWca WofWca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks quite simple overall, and I like the idea. It's an important thing.

sim/webxdc.ts Outdated
Comment on lines 28 to 34
const isAllowed =
event.origin.includes("localhost:") ||
(location.host.endsWith(".webcontainer.io") &&
event.origin.includes(".webcontainer.io"));
if (!isAllowed) {
return;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice not to copy-paste this code, especially if it's security-related

webxdc-dev/sim/webxdc.ts

Lines 136 to 147 in f2d1f43

window.addEventListener("message", (event) => {
const isAllowed =
event.origin.includes("localhost:") ||
(location.host.endsWith(".webcontainer.io") &&
event.origin.includes(".webcontainer.io"));
if (!isAllowed) {
return;
}
if (event.data === "reload") {
window.location.reload();
}
});

@hpk42
Copy link
Contributor

hpk42 commented Dec 17, 2025 via email

@jackaperkins
Copy link
Author

Welcome into the new year 😁 I've updated the PR.
I've improved the language in the readme slightly, but it is a complex thing to explain relative to how the backend works. Also factored the duplicated code into a function.

@WofWca
Copy link
Member

WofWca commented Jan 8, 2026

What do you have in mind here when you say "security-related"?

The code I'm talking about is about security, protecting against unauthorized access. Any website can win = window.open('http://localhost:7000') and then win.postMessage. We must check whether the message is trusted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants